package netty.fry;

/**
 * @Author zhangtao
 * @create 2021/12/28 15:02
 */
public class Read {
    public static void main(String[] args) {
        String service = "Common Information\n" +
                "------------------\n" +
                "Date and Time.................: 20211228141947 \n" +
                "Startup Date and Time.........: 20190827060958 \n" +
                "Unit type.....................: SCC_101 \n" +
                "Energy type...................: E \n" +
                "Unit Serial number............: E11SI18122714740 \n" +
                "Software version..............: SCC-07-00-09.1DYI \n" +
                " Script version................: KFC_CN_07-82\n" +
                "SW-update Date and Time.......: 20200320113029 \n" +
                "CPU-Board Revision............: 0301 \n" +
                "CPU-Board Serial number.......: 26473604 \n" +
                "CPU-Board Manufacturing date..: 2018-11-19 09:54:42 \n" +
                "Burner Control 0 Serial number:  \n" +
                "Burner Control 0 SW-version...:  \n" +
                "Burner Control 1 Serial number:  \n" +
                "Burner Control 1 SW-version...:  \n" +
                "Fan M1 Serial number..........: 1848005USY1A \n" +
                "Fan M2 Serial number..........:  \n" +
                "Language......................: chinese_new \n" +
                "Status Ultravent..............:    DEACT \n";
        int sv_start = service.indexOf("Software version", 0);
        int sv_end = service.indexOf("\n", sv_start);
        String softwareRevision = service.substring(sv_start, sv_end);

        int hv_start = service.indexOf("Script version", 0);
        int hv_end = service.indexOf("\n", hv_start);
        String hardwareRevision = service.substring(hv_start, hv_end);

        System.out.println(softwareRevision);
        System.out.println(softwareRevision.split(":")[1].trim());
        System.out.println(hardwareRevision);
        System.out.println(hardwareRevision.split(":")[1].trim());
    }

    public static String getVal(String text, String name) {
        int start = text.indexOf(name, 0);
        if (start != -1) {
            int end = text.indexOf("\n", start);
            if (end != -1) {
                String match = text.substring(start, end);
                return match.split(":")[1].trim();
            } else {
                String match = text.substring(start);
                return match.split(":")[1].trim();
            }
        }
        return "";
    }
}
